//
//  AddressManageCell.m
//  BakingTown
//
//  Created by yaoqi yaoqi on 2018/4/8.
//  Copyright © 2018年 duandonggang. All rights reserved.
//

#import "AddressManageCell.h"
#import "UIButton+SSEdgeInsets.h"
@interface AddressManageCell()
@property(nonatomic,strong)UILabel *chooseAddress_nameLable;
@property(nonatomic,strong)UILabel *chooseAddress_phoneNumberLable;
@property(nonatomic,strong)UILabel *chooseAddress_detailsAddressLable;
@property(nonatomic , strong) UILabel * statelb;
@property(nonatomic , strong) UIView * lineV;

@end
@implementation AddressManageCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //姓名
        UILabel *name = [[UILabel alloc]init];
        name.font = BoldFont(14);
        [self.contentView addSubview:name];
        self.chooseAddress_nameLable = name;
        //电话
        UILabel *phone = [[UILabel alloc]init];
        phone.font = MediumFont(12);
        phone.textColor = rgb_153;
        [self.contentView addSubview:phone];
        self.chooseAddress_phoneNumberLable = phone;
        //详细地址
        UILabel *detailsAddress = [[UILabel alloc]init];
        detailsAddress.numberOfLines = 2;
        detailsAddress.textColor = rgb_51;
        detailsAddress.font = MediumFont(13);
        [self.contentView addSubview:detailsAddress];
        self.chooseAddress_detailsAddressLable = detailsAddress;

        //编辑
        UIButton *btn_ed = [[UIButton alloc]init];
        [self.contentView addSubview:btn_ed];
        [btn_ed setTitle:@"编辑" forState:0];
        [btn_ed setTitleColor:rgb_153 forState:0];
        btn_ed.titleLabel.font = MediumFont(14);
        
        self.editorBtn = btn_ed;
        //默认地址
        UILabel *label = [[UILabel alloc]init];
        label.textColor = rgb(255,138,10);
        label.font = MediumFont(11);
        label.backgroundColor = rgba(255,180,36,0.1);
        [self.contentView addSubview:label];
        self.statelb = label;
        
        //
        UIView *line = [[UIView alloc]init];
        line.backgroundColor = rgb(232,232,232);
        [self.contentView addSubview:line];
        self.lineV = line;
        
        
        

    }
    return self;
}
-(void)setDict:(NSDictionary *)dict{
    _dict = dict;
    //姓名
    self.chooseAddress_nameLable.text = [NSString stringWithFormat:@"%@",dict[@"consignee"]];
    CGFloat namewidth = [ToolClass getWidthWithTextLable:self.chooseAddress_nameLable font:BoldFont(14)];
    self.chooseAddress_nameLable.frame = CGRectMake(15, 15, namewidth, 13);
    //电话
    self.chooseAddress_phoneNumberLable.text = [NSString stringWithFormat:@"%@",dict[@"phone"]];
    CGFloat phoneWidth = [ToolClass getWidthWithTextLable:self.chooseAddress_phoneNumberLable font:MediumFont(13)];
    self.chooseAddress_phoneNumberLable.frame = CGRectMake(self.chooseAddress_nameLable.right +5, self.chooseAddress_nameLable.yv, phoneWidth, 13);
    
    self.statelb.text = @"默认";
    self.statelb.textAlignment = NSTextAlignmentCenter;
    self.statelb.frame = CGRectMake(self.chooseAddress_phoneNumberLable.right + 5, self.chooseAddress_nameLable.yv, 35, 13);
    if (self.isDefultAddress) {
        self.statelb.hidden = NO;
    }else{
         self.statelb.hidden = YES;
    }
    //详细地址
    self.chooseAddress_detailsAddressLable.text = [NSString stringWithFormat:@"地址: %@",dict[@"fullAddress"]];
    float addressH = [self.chooseAddress_detailsAddressLable.text boundingRectWithSize:CGSizeMake(KScreenWidth - 85, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :MediumFont(13)} context:nil].size.height;
    
    self.chooseAddress_detailsAddressLable.frame = CGRectMake(self.chooseAddress_nameLable.xv, self.chooseAddress_nameLable.bottom + 5, KScreenWidth -85, addressH);
    //线
    self.lineV.frame = CGRectMake(KScreenWidth - 70, self.chooseAddress_phoneNumberLable.top + 10, 1, 23);

    //编辑按钮
    self.editorBtn.frame = CGRectMake(KScreenWidth - 65, self.lineV.yv, 50, 23);
    //cell高度
    self.height = self.chooseAddress_detailsAddressLable.bottom + 10;
    
}




@end
